#include <iostream>

using namespace std;

void qSort(int arr[],int left,int right){
	int key,i,j;

	if(left >= right){
		return ;
	}

	key=arr[(left+right)/2];

	i=left,j=right;

	do{
		while(arr[i]<key) i++;
		while(arr[j]>key) j--;

		if(i<=j){
			int tmp=arr[j];
			arr[j]=arr[i];
			arr[i]=tmp;
			i++;
			j--;
		}
	}while(i<=j);

	qSort(arr,i,right);
	qSort(arr,left,j);

}
int main(){
	int arr[10]={9,7,20,35,7,88,49,2,9,0};

	for(int i=0;i<10;i++){
		cout<<arr[i]<<" ";
	}
	cout<<endl;

	qSort(arr,0,9);
	for(int i=0;i<10;i++){
		cout<<arr[i]<<" ";
	}
	cout<<endl;
	return 0;
}
